home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 April: Mac OS SDK / Dev.CD Apr 96 SDK / Dev.CD Apr 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc Development Framework / ODFDev / ODF / OS / FWGraphx / Sources / FWMaping.cpp < prev    next >
Encoding:
Text File  |  1995-11-08  |  22.7 KB  |  810 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                FWMaping.cpp
  4. //    Release Version:    $ 1.0d11 $
  5. //
  6. //    Copyright:    © 1993, 1995 by Apple Computer, Inc., all rights reserved.
  7. //
  8. //========================================================================================
  9.  
  10. #include "FWOS.hpp"
  11.  
  12. #if defined(FW_PROFILER_CALLS) && defined(__MWERKS__)
  13. #pragma profile on
  14. #endif
  15.  
  16. #ifndef FWMAPING_H
  17. #include "FWMaping.h"
  18. #endif
  19.  
  20. #ifndef FWGDEV_H
  21. #include "FWGDev.h"
  22. #endif
  23.  
  24. #ifndef FWGRUTIL_H
  25. #include "FWGrUtil.h"
  26. #endif
  27.  
  28. #ifndef FWGRGLOB_H
  29. #include "FWGrGlob.h"
  30. #endif
  31.  
  32. #ifndef FWODUTIL_H
  33. #include "FWODUtil.h"
  34. #endif
  35.  
  36. #ifndef FWGRUTIL_H
  37. #include "FWGrUtil.h"
  38. #endif
  39.  
  40. #ifndef FWREGION_H
  41. #include "FWRegion.h"
  42. #endif
  43.  
  44. // ----- OpenDoc Includes -----
  45.  
  46. #ifndef SOM_ODTransform_xh
  47. #include <Trnsform.xh>
  48. #endif
  49.  
  50. #ifndef SOM_ODShape_xh
  51. #include <Shape.xh>
  52. #endif
  53.  
  54. //========================================================================================
  55. //    RunTime Info
  56. //========================================================================================
  57.  
  58. #if FW_LIB_EXPORT_PRAGMAS
  59. #pragma lib_export on
  60. #endif
  61.  
  62. #ifdef FW_BUILD_MAC
  63. #pragma segment FWGraphics_Mapping
  64. #endif
  65.  
  66. //========================================================================================
  67. //    class FW_CMapping
  68. //========================================================================================
  69.  
  70. //----------------------------------------------------------------------------------------
  71. //    FW_CMapping::FW_CMapping
  72. //----------------------------------------------------------------------------------------
  73.  
  74. FW_CMapping::FW_CMapping() :
  75.     fMappingMode(FW_kPoint),
  76.     fRecentDevice(NULL),
  77.     fRecentODTransform(NULL),
  78.     fLogicalToContentTransform(NULL),
  79.     fContentToDeviceTransform(NULL),
  80.     fLogicalToDeviceTransform(NULL),
  81.     fHaveTransforms(FALSE)
  82.         // fDeviceOrg and fLogicalOrg are set to 0's by default constructor
  83. {
  84.     fLogicalExtent.x =
  85.     fLogicalExtent.y =
  86.     fDeviceExtent.x =
  87.     fDeviceExtent.y = FW_kFixedPos1;
  88. }
  89.  
  90. //----------------------------------------------------------------------------------------
  91. //    FW_CMapping::FW_CMapping
  92. //----------------------------------------------------------------------------------------
  93.  
  94. FW_CMapping::FW_CMapping(FW_EMappingModes mappingMode) :
  95.     fMappingMode(mappingMode),
  96.     fRecentDevice(NULL),
  97.     fRecentODTransform(NULL),
  98.     fLogicalToContentTransform(NULL),
  99.     fContentToDeviceTransform(NULL),
  100.     fLogicalToDeviceTransform(NULL),
  101.     fHaveTransforms(FALSE)
  102.         // fDeviceOrg and fLogicalOrg are set to 0's by default constructor
  103. {
  104.     fLogicalExtent.x =
  105.     fLogicalExtent.y =
  106.     fDeviceExtent.x =
  107.     fDeviceExtent.y = FW_kFixedPos1;
  108. }
  109.  
  110. //----------------------------------------------------------------------------------------
  111. //    FW_CMapping::FW_CMapping
  112. //----------------------------------------------------------------------------------------
  113.  
  114. FW_CMapping::FW_CMapping(const FW_CMapping& mapping) :
  115.     fMappingMode(mapping.fMappingMode),
  116.     fRecentDevice(NULL),
  117.     fRecentODTransform(NULL),
  118.     fLogicalToContentTransform(NULL),
  119.     fContentToDeviceTransform(NULL),
  120.     fLogicalToDeviceTransform(NULL),
  121.     fHaveTransforms(FALSE),
  122.     fLogicalExtent(mapping.fLogicalExtent),
  123.     fDeviceExtent(mapping.fDeviceExtent),
  124.     fDeviceOrg(mapping.fDeviceOrg),
  125.     fLogicalOrg(mapping.fLogicalOrg)
  126. {
  127. }
  128.  
  129. //----------------------------------------------------------------------------------------
  130. //    FW_CMapping::~FW_CMapping
  131. //----------------------------------------------------------------------------------------
  132.  
  133. FW_CMapping::~FW_CMapping()
  134. {
  135.     ClearCache(somGetGlobalEnvironment());
  136. }
  137.  
  138. //----------------------------------------------------------------------------------------
  139. //    FW_CMapping::operator=
  140. //----------------------------------------------------------------------------------------
  141.  
  142. FW_CMapping& FW_CMapping::operator=(const FW_CMapping& mapping)
  143. {
  144.     if (&mapping != this)
  145.     {
  146.         ClearCache(somGetGlobalEnvironment());
  147.     
  148.         fMappingMode = mapping.fMappingMode;
  149.         fLogicalExtent = mapping.fLogicalExtent;
  150.         fDeviceExtent = mapping.fDeviceExtent;
  151.         fDeviceOrg = mapping.fDeviceOrg;
  152.         fLogicalOrg = mapping.fLogicalOrg;
  153.     }
  154.  
  155.     return *this;
  156. }
  157.  
  158. //----------------------------------------------------------------------------------------
  159. //    FW_CMapping::operator==
  160. //----------------------------------------------------------------------------------------
  161.  
  162. FW_Boolean FW_CMapping::operator==(const FW_CMapping& mapping) const
  163. {
  164.     return (fMappingMode == mapping.fMappingMode &&
  165.             fLogicalExtent == mapping.fLogicalExtent &&
  166.             fDeviceExtent == mapping.fDeviceExtent && 
  167.             fDeviceOrg == mapping.fDeviceOrg &&
  168.             fLogicalOrg == mapping.fLogicalOrg);
  169. }
  170.  
  171. //----------------------------------------------------------------------------------------
  172. //    FW_CMapping::Reset
  173. //----------------------------------------------------------------------------------------
  174.  
  175. void FW_CMapping::Reset(Environment* ev)
  176. {
  177.     ClearCache(ev);
  178.     
  179.     fMappingMode = FW_kPoint;
  180.  
  181.     fLogicalExtent.x =
  182.     fLogicalExtent.y =
  183.     fDeviceExtent.x =
  184.     fDeviceExtent.y = FW_kFixedPos1;
  185.  
  186.     fDeviceOrg = FW_kZeroPoint;
  187.     fLogicalOrg = FW_kZeroPoint;
  188. }
  189.  
  190. //----------------------------------------------------------------------------------------
  191. //    FW_CMapping::SetMappingMode
  192. //----------------------------------------------------------------------------------------
  193.  
  194. void FW_CMapping::SetMappingMode(Environment* ev, FW_EMappingModes newMappingMode)
  195. {
  196.     fMappingMode = newMappingMode;
  197.     
  198.     if (fMappingMode == FW_kCustomConstrained)
  199.         SetExtents(ev, fLogicalExtent, fDeviceExtent);    // already calls ClearCache
  200.     else
  201.         ClearCache(ev);
  202. }
  203.  
  204. //----------------------------------------------------------------------------------------
  205. //    FW_CMapping::SetExtents
  206. //----------------------------------------------------------------------------------------
  207.  
  208. void FW_CMapping::SetExtents(Environment* ev,
  209.                              const FW_CPoint& logicalExtent,
  210.                              const FW_CPoint& deviceExtent)
  211. {
  212.     fLogicalExtent = logicalExtent;
  213.     fDeviceExtent = deviceExtent;
  214.     
  215.     if (fMappingMode == FW_kCustomConstrained)
  216.     {
  217.         if (fDeviceExtent.x < fDeviceExtent.y)
  218.             fDeviceExtent.y = fDeviceExtent.x;
  219.         else
  220.             fDeviceExtent.x = fDeviceExtent.y;
  221.     }
  222.     
  223.     ClearCache(ev);
  224. }
  225.  
  226. //----------------------------------------------------------------------------------------
  227. //    FW_CMapping::SetDeviceOrigin
  228. //----------------------------------------------------------------------------------------
  229.  
  230. void FW_CMapping::SetDeviceOrigin(Environment* ev, FW_CFixed x, FW_CFixed y)
  231. {
  232.     fDeviceOrg.Set(x, y);
  233.     ClearCache(ev);
  234. }
  235.  
  236. //----------------------------------------------------------------------------------------
  237. //    FW_CMapping::SetLogicalOrigin
  238. //----------------------------------------------------------------------------------------
  239.  
  240. void FW_CMapping::SetLogicalOrigin(Environment* ev, FW_CFixed x, FW_CFixed y)
  241. {
  242.     fLogicalOrg.Set(x, y);
  243.     ClearCache(ev);
  244. }
  245.  
  246. //----------------------------------------------------------------------------------------
  247. //    FW_CMapping::ClearCache
  248. //----------------------------------------------------------------------------------------
  249.  
  250. void FW_CMapping::ClearCache(Environment* ev)
  251. {
  252.     if (fRecentDevice != NULL)
  253.     {
  254.         fRecentDevice->Release();
  255.         fRecentDevice = NULL;
  256.     }
  257.  
  258.     if (fRecentODTransform != NULL)
  259.     {
  260.         fRecentODTransform->Release(ev);
  261.         fRecentODTransform = NULL;
  262.     }
  263.  
  264.     if (fLogicalToContentTransform != NULL)
  265.     {
  266.         fLogicalToContentTransform->Release(ev);
  267.         fLogicalToContentTransform = NULL;
  268.     }
  269.  
  270.     if (fContentToDeviceTransform != NULL)
  271.     {
  272.         fContentToDeviceTransform->Release(ev);
  273.         fContentToDeviceTransform = NULL;
  274.     }
  275.  
  276.     if (fLogicalToDeviceTransform != NULL)
  277.     {
  278.         fLogicalToDeviceTransform->Release(ev);
  279.         fLogicalToDeviceTransform = NULL;
  280.     }
  281.     
  282.     fHaveTransforms = FALSE;
  283. }
  284.  
  285. //----------------------------------------------------------------------------------------
  286. //    FW_CMapping::CheckCache
  287. //----------------------------------------------------------------------------------------
  288.  
  289. void FW_CMapping::CheckCache(
  290.     Environment* ev,
  291.     FW_CGraphicDevice* device,
  292.     ODTransform* transform) const
  293. {
  294.     if (!fHaveTransforms || device != fRecentDevice || transform != fRecentODTransform)
  295.         ((FW_CMapping*) this)->CalcCache(ev, device, transform);
  296.  
  297.     FW_ASSERT(fHaveTransforms);
  298.     FW_ASSERT(fLogicalToContentTransform != NULL);
  299.     FW_ASSERT(fContentToDeviceTransform != NULL);
  300.     FW_ASSERT(fLogicalToDeviceTransform != NULL);
  301. }
  302.  
  303. //----------------------------------------------------------------------------------------
  304. //    FW_CMapping::CalcCache
  305. //----------------------------------------------------------------------------------------
  306.  
  307. void FW_CMapping::CalcCache(
  308.     Environment* ev,
  309.     FW_CGraphicDevice* device,
  310.     ODTransform* transform)
  311. {
  312. // #define LOG_TRANSFORMS
  313.  
  314.     ClearCache(ev);
  315.  
  316.     fRecentDevice = device;
  317.     if(fRecentDevice != NULL)
  318.     {
  319.         fRecentDevice->Acquire();
  320.     }
  321.         
  322.     fRecentODTransform = transform;
  323.     if(fRecentODTransform != NULL) 
  324.     {
  325. #ifdef FW_BUILD_WIN
  326.         fRecentODTransform->IncrementRefCount(ev);
  327. #endif
  328. #ifdef FW_BUILD_MAC
  329.         fRecentODTransform->Acquire(ev);
  330. #endif
  331.     }
  332.  
  333.     ODCanvas* canvas = device != NULL ? device->GetODCanvas() : NULL;
  334.     
  335.     FW_CPoint resScreen;
  336. #ifdef FW_BUILD_WIN
  337.     HDC hDC = ::GetDC(NULL);
  338.  
  339.     resScreen.x.SetInt(::GetDeviceCaps(hDC, LOGPIXELSX));
  340.     resScreen.y.SetInt(::GetDeviceCaps(hDC, LOGPIXELSY));
  341.  
  342.     ::ReleaseDC(NULL, hDC);
  343.     
  344.     BOOL bWinIsPrinting = canvas != NULL ? canvas->HasPlatformPrintJob(ev, kODWindows) : FALSE;
  345. #endif
  346. #ifdef FW_BUILD_MAC
  347.     resScreen.Set(FW_kFixed72, FW_kFixed72);
  348. #endif
  349.  
  350.     FW_CPoint resDevice = device == NULL ? resScreen : device->GetResolution(ev);
  351.         
  352.     FW_CPoint ptLogicalToContentOffset(-fLogicalOrg.x, -fLogicalOrg.y);
  353.     FW_CPoint ptLogicalToContentScaling;
  354.     FW_CPoint resScale;
  355.  
  356.     switch (fMappingMode)
  357.     {
  358.         case FW_kCentimeter:
  359.             ptLogicalToContentScaling.x = FW_DoubleToFixed(28.346456691);
  360.             ptLogicalToContentScaling.y = FW_DoubleToFixed(28.346456691);
  361.             break;
  362.  
  363.         case FW_kInch:
  364.             ptLogicalToContentScaling.x = FW_kFixed72;
  365.             ptLogicalToContentScaling.y = FW_kFixed72;
  366.             break;
  367.  
  368.         case FW_kPoint:    
  369.             //    On the Mac:
  370.             //        The screen is always assumed to be 72dpi, even though actual
  371.             //        resolution may vary (this is the tradition!)
  372.             //    On Windows:
  373.             //        OpenDoc/Win emulates 72dpi
  374.             ptLogicalToContentScaling.x = FW_kFixedPos1;
  375.             ptLogicalToContentScaling.y = FW_kFixedPos1;
  376.             break;
  377.  
  378.         case FW_kDevice:
  379. #ifdef FW_BUILD_MAC
  380.             ptLogicalToContentScaling.x = FW_kFixedPos1;
  381.             ptLogicalToContentScaling.y = FW_kFixedPos1;
  382. #endif
  383. #ifdef FW_BUILD_WIN
  384.             if (bWinIsPrinting)
  385.             {
  386.                 // For printing, preserve the visual image size
  387.                 ptLogicalToContentScaling.x = FW_kFixed72 / resScreen.x;
  388.                 ptLogicalToContentScaling.y = FW_kFixed72 / resScreen.y;
  389.             }
  390.             else
  391.             {
  392.                 // Counter-act OpenDoc's 72 dpi emulation
  393.                 ptLogicalToContentScaling.x = FW_kFixed72 / resDevice.x;
  394.                 ptLogicalToContentScaling.y = FW_kFixed72 / resDevice.y;
  395.             }
  396. #endif
  397.             break;
  398.  
  399.         case FW_kCustomConstrained:
  400.         case FW_kCustomUnconstrained:
  401.             resScale.x = FW_kFixed72 / resDevice.x;
  402.             resScale.y = FW_kFixed72 / resDevice.y;
  403.  
  404.             ptLogicalToContentScaling.x =
  405.                 FW_WideMultiply(resScale.x, fDeviceExtent.x) / fLogicalExtent.x;
  406.                 
  407.             ptLogicalToContentScaling.y =
  408.                 FW_WideMultiply(resScale.y, fDeviceExtent.y) / fLogicalExtent.y;
  409.  
  410.             ptLogicalToContentOffset.x  = 
  411.                 FW_WideMultiply(fDeviceOrg.x, FW_kFixed72) / resDevice.x - fLogicalOrg.x * ptLogicalToContentScaling.x;
  412.  
  413.             ptLogicalToContentOffset.y  =
  414.                 FW_WideMultiply(fDeviceOrg.y, FW_kFixed72) / resDevice.y - fLogicalOrg.y * ptLogicalToContentScaling.y;
  415.  
  416.             break;
  417.     }
  418.  
  419.     // ----- Logical to content transform
  420.     fLogicalToContentTransform = ::FW_NewODTransform(ev, ptLogicalToContentOffset, ptLogicalToContentScaling);
  421.  
  422.     // ----- Content to device transform
  423.     if(transform != NULL)
  424.     {
  425. #ifdef LOG_TRANSFORMS
  426.         FW_LogTransform(ev, "OD Content        ", transform);
  427. #endif
  428.         fContentToDeviceTransform = ::FW_NewODTransform(ev, transform);
  429.     }
  430.     else
  431.     {
  432.         FW_CPoint scaling;
  433. #ifdef FW_BUILD_WIN
  434.         if (bWinIsPrinting && fMappingMode == FW_kDevice)
  435.         {
  436.             // Preserve visual image size
  437.             scaling.x = resScreen.x / FW_kFixed72;
  438.             scaling.y = resScreen.y / FW_kFixed72;
  439.         }
  440.         else
  441. #endif
  442.         {
  443.             scaling.x = resDevice.x / FW_kFixed72;
  444.             scaling.y = resDevice.y / FW_kFixed72;
  445.         }
  446.  
  447.         fContentToDeviceTransform = ::FW_NewODTransform(ev);
  448.         fContentToDeviceTransform->ScaleBy(ev, (ODPoint*) &scaling);        
  449.     }
  450.  
  451.     // ------ Logical to device transform -----
  452.     fLogicalToDeviceTransform = ::FW_NewODTransform(ev, fLogicalToContentTransform);
  453.     fLogicalToDeviceTransform->PostCompose(ev, fContentToDeviceTransform);
  454.  
  455.     // ----- Adjust the origin
  456.     CalcOriginOffset(ev, device);
  457.  
  458. #ifdef LOG_TRANSFORMS
  459.     FW_LogTransform(ev, "Logical -> Content", fLogicalToContentTransform);
  460.     FW_LogTransform(ev, "Content -> Device ", fContentToDeviceTransform);
  461.     FW_LogTransform(ev, "Logical -> Device ", fLogicalToDeviceTransform);
  462. #endif
  463.  
  464.     fHaveTransforms = TRUE;
  465. }
  466.  
  467. //----------------------------------------------------------------------------------------
  468. //    FW_CMapping::CalcOriginOffset
  469. //----------------------------------------------------------------------------------------
  470.  
  471. void FW_CMapping::CalcOriginOffset(
  472.         Environment* ev,
  473.         FW_CGraphicDevice* device)
  474. {
  475.     ODCanvas* canvas = device != NULL ? device->GetODCanvas() : NULL;
  476.     FW_Boolean isPrinting = canvas != NULL && 
  477. #ifdef FW_BUILD_WIN
  478.         canvas->HasPlatformPrintJob(ev, kODWindows);
  479. #endif
  480. #ifdef FW_BUILD_MAC
  481.         canvas->HasPlatformPrintJob(ev, kODQuickDraw);
  482. #endif
  483.  
  484.     FW_CPoint offset;
  485.     fLogicalToDeviceTransform->GetOffset(ev, (ODPoint*) &offset);
  486.     if ((offset.x || offset.y) && !isPrinting)
  487.     {
  488.         fOriginOffset.Set(offset.x.AsInt() % 8, offset.y.AsInt() % 8);
  489.         offset.x.SetInt(-fOriginOffset.X());
  490.         offset.y.SetInt(-fOriginOffset.Y());
  491.         fLogicalToDeviceTransform->MoveBy(ev, (ODPoint*) &offset);
  492.     }
  493.     else
  494.     {
  495.         fOriginOffset.Set(0, 0);
  496.     }
  497. }
  498.  
  499. //----------------------------------------------------------------------------------------
  500. //    FW_CMapping::GetOriginOffset
  501. //----------------------------------------------------------------------------------------
  502.  
  503. FW_SPlatformPoint FW_CMapping::GetOriginOffset(
  504.     Environment* ev,
  505.     FW_CGraphicDevice* device,
  506.     ODTransform* transform) const
  507. {
  508.     CheckCache(ev, device, transform);
  509.  
  510.     return fOriginOffset;
  511. }
  512.  
  513. //----------------------------------------------------------------------------------------
  514. //    FW_CMapping::LogicalToContent
  515. //----------------------------------------------------------------------------------------
  516.  
  517. void FW_CMapping::LogicalToContent(
  518.     Environment* ev,
  519.     const FW_CPoint& ptFrom,
  520.     FW_CPoint& ptTo,
  521.     FW_CGraphicDevice* device,
  522.     ODTransform* transform) const
  523. {
  524.     CheckCache(ev, device, transform);
  525.  
  526.     ptTo = ptFrom.TransformCopy(ev, fLogicalToContentTransform);
  527. }
  528.  
  529. //----------------------------------------------------------------------------------------
  530. //    FW_CMapping::LogicalToContent
  531. //----------------------------------------------------------------------------------------
  532.  
  533. void FW_CMapping::LogicalToContent(
  534.     Environment* ev,
  535.     const FW_CRect& rectFrom,
  536.     FW_CRect& rectTo,
  537.     FW_CGraphicDevice* device,
  538.     ODTransform* transform) const
  539. {
  540.     CheckCache(ev, device, transform);
  541.  
  542.     rectTo = rectFrom.TransformCopy(ev, fLogicalToContentTransform);
  543. }
  544.  
  545. //----------------------------------------------------------------------------------------
  546. //    FW_CMapping::LogicalToContent
  547. //----------------------------------------------------------------------------------------
  548.  
  549. ODShape* FW_CMapping::LogicalToContent(
  550.                         Environment* ev,
  551.                         ODShape* shape,
  552.                         FW_CGraphicDevice* device,
  553.                         ODTransform* transform) const
  554. {                        
  555.     CheckCache(ev, device, transform);
  556.  
  557.     ODShape* newShape = shape->Copy(ev);
  558.     fLogicalToContentTransform->TransformShape(ev, newShape);
  559.     return newShape;
  560. }                            
  561.  
  562. //----------------------------------------------------------------------------------------
  563. //    FW_CMapping::LogicalToDevice
  564. //----------------------------------------------------------------------------------------
  565.  
  566. void FW_CMapping::LogicalToDevice(
  567.     Environment* ev,
  568.     const FW_CPoint& ptFrom,
  569.     FW_SPlatformPoint& ptTo,
  570.     FW_CGraphicDevice* device,
  571.     ODTransform* transform) const
  572. {
  573.     CheckCache(ev, device, transform);
  574.  
  575.     ptTo = ptFrom.TransformCopy(ev, fLogicalToDeviceTransform);
  576. }
  577.  
  578. //----------------------------------------------------------------------------------------
  579. //    FW_CMapping::LogicalToDevice
  580. //----------------------------------------------------------------------------------------
  581.  
  582. void FW_CMapping::LogicalToDevice(
  583.     Environment* ev,
  584.     const FW_CRect& rectFrom,
  585.     FW_SPlatformRect& rectTo,
  586.     FW_CGraphicDevice* device,
  587.     ODTransform* transform) const
  588. {
  589.     CheckCache(ev, device, transform);
  590.  
  591.     rectTo = rectFrom.TransformCopy(ev, fLogicalToDeviceTransform);
  592. }
  593.  
  594. //----------------------------------------------------------------------------------------
  595. //    FW_CMapping::LogicalToDevice
  596. //----------------------------------------------------------------------------------------
  597.  
  598. ODShape* FW_CMapping::LogicalToDevice(
  599.                         Environment* ev,
  600.                         ODShape* shape,
  601.                         FW_CGraphicDevice* device,
  602.                         ODTransform* transform) const
  603. {                        
  604.     CheckCache(ev, device, transform);
  605.  
  606.     ODShape* newShape = shape->Copy(ev);
  607.     fLogicalToDeviceTransform->TransformShape(ev, newShape);
  608.     return newShape;
  609. }                            
  610.  
  611. //----------------------------------------------------------------------------------------
  612. //    FW_CMapping::DeviceToLogical
  613. //----------------------------------------------------------------------------------------
  614.  
  615. void FW_CMapping::DeviceToLogical(
  616.     Environment* ev,
  617.     const FW_SPlatformPoint& ptFrom,
  618.     FW_CPoint& ptTo,
  619.     FW_CGraphicDevice* device,
  620.     ODTransform* transform) const
  621. {
  622.     CheckCache(ev, device, transform);
  623.  
  624.     FW_CPoint pt = ptFrom;
  625.     ptTo = pt.InverseTransformCopy(ev, fLogicalToDeviceTransform);
  626. }
  627.  
  628. //----------------------------------------------------------------------------------------
  629. //    FW_CMapping::DeviceToLogical
  630. //----------------------------------------------------------------------------------------
  631.  
  632. void FW_CMapping::DeviceToLogical(
  633.     Environment* ev,
  634.     const FW_SPlatformRect& rectFrom,
  635.     FW_CRect& rectTo,
  636.     FW_CGraphicDevice* device,
  637.     ODTransform* transform) const
  638. {
  639.     CheckCache(ev, device, transform);
  640.  
  641.     FW_CRect rect = rectFrom;
  642.     rectTo = rect.InverseTransformCopy(ev, fLogicalToDeviceTransform);
  643. }
  644.  
  645. //----------------------------------------------------------------------------------------
  646. //    FW_CMapping::DeviceToLogical
  647. //----------------------------------------------------------------------------------------
  648.  
  649. ODShape* FW_CMapping::DeviceToLogical(
  650.     Environment* ev,
  651.     ODShape* shape,
  652.     FW_CGraphicDevice* device,
  653.     ODTransform* transform) const
  654. {
  655.     CheckCache(ev, device, transform);
  656.  
  657.     ODShape* newShape = shape->Copy(ev);
  658.     fLogicalToDeviceTransform->InvertShape(ev, newShape);
  659.     return newShape;
  660. }
  661.  
  662. //----------------------------------------------------------------------------------------
  663. //    FW_CMapping::DeviceToContent
  664. //----------------------------------------------------------------------------------------
  665.  
  666. void FW_CMapping::DeviceToContent(
  667.     Environment* ev,
  668.     const FW_SPlatformPoint& ptFrom,
  669.     FW_CPoint& ptTo,
  670.     FW_CGraphicDevice* device,
  671.     ODTransform* transform) const
  672. {
  673.     CheckCache(ev, device, transform);
  674.  
  675.     FW_CPoint pt = ptFrom;
  676.     ptTo = pt.InverseTransformCopy(ev, fContentToDeviceTransform);
  677. }
  678.  
  679. //----------------------------------------------------------------------------------------
  680. //    FW_CMapping::DeviceToContent
  681. //----------------------------------------------------------------------------------------
  682.  
  683. void FW_CMapping::DeviceToContent(
  684.     Environment* ev,
  685.     const FW_SPlatformRect& rectFrom,
  686.     FW_CRect& rectTo,
  687.     FW_CGraphicDevice* device,
  688.     ODTransform* transform) const
  689. {
  690.     CheckCache(ev, device, transform);
  691.  
  692.     FW_CRect rect = rectFrom;
  693.     rectTo = rect.InverseTransformCopy(ev, fContentToDeviceTransform);
  694. }
  695.  
  696. //----------------------------------------------------------------------------------------
  697. //    FW_CMapping::DeviceToContent
  698. //----------------------------------------------------------------------------------------
  699.  
  700. ODShape* FW_CMapping::DeviceToContent(
  701.     Environment* ev,
  702.     ODShape* shape,
  703.     FW_CGraphicDevice* device,
  704.     ODTransform* transform) const
  705. {
  706.     CheckCache(ev, device, transform);
  707.  
  708.     ODShape* newShape = shape->Copy(ev);
  709.     fContentToDeviceTransform->InvertShape(ev, newShape);
  710.     return newShape;
  711. }
  712.  
  713. //----------------------------------------------------------------------------------------
  714. //    FW_CMapping::ContentToLogical
  715. //----------------------------------------------------------------------------------------
  716.  
  717. void FW_CMapping::ContentToLogical(
  718.     Environment* ev,
  719.     const FW_CPoint& ptFrom,
  720.     FW_CPoint& ptTo,
  721.     FW_CGraphicDevice* device,
  722.     ODTransform* transform) const
  723. {
  724.     CheckCache(ev, device, transform);
  725.  
  726.     ptTo = ptFrom.InverseTransformCopy(ev, fLogicalToContentTransform);
  727. }    
  728.  
  729. //----------------------------------------------------------------------------------------
  730. //    FW_CMapping::ContentToLogical
  731. //----------------------------------------------------------------------------------------
  732.  
  733. void FW_CMapping::ContentToLogical(
  734.     Environment* ev,
  735.     const FW_CRect& rectFrom,
  736.     FW_CRect& rectTo,
  737.     FW_CGraphicDevice* device,
  738.     ODTransform* transform) const
  739. {
  740.     CheckCache(ev, device, transform);
  741.  
  742.     rectTo = rectFrom.InverseTransformCopy(ev, fLogicalToContentTransform);
  743. }
  744.  
  745. //----------------------------------------------------------------------------------------
  746. //    FW_CMapping::ContentToLogical
  747. //----------------------------------------------------------------------------------------
  748.  
  749. ODShape* FW_CMapping::ContentToLogical(
  750.     Environment* ev,
  751.     ODShape* shape,
  752.     FW_CGraphicDevice* device,
  753.     ODTransform* transform) const
  754. {
  755.     CheckCache(ev, device, transform);
  756.  
  757.     ODShape* newShape = shape->Copy(ev);
  758.     fLogicalToContentTransform->InvertShape(ev, newShape);
  759.     return newShape;
  760. }
  761.  
  762. //----------------------------------------------------------------------------------------
  763. //    FW_CMapping::ContentToDevice
  764. //----------------------------------------------------------------------------------------
  765.  
  766. void FW_CMapping::ContentToDevice(
  767.     Environment* ev,
  768.     const FW_CPoint& ptFrom,
  769.     FW_SPlatformPoint& ptTo,
  770.     FW_CGraphicDevice* device,
  771.     ODTransform* transform) const
  772. {
  773.     CheckCache(ev, device, transform);
  774.  
  775.     ptTo = ptFrom.TransformCopy(ev, fContentToDeviceTransform);
  776. }
  777.  
  778. //----------------------------------------------------------------------------------------
  779. //    FW_CMapping::ContentToDevice
  780. //----------------------------------------------------------------------------------------
  781.  
  782. void FW_CMapping::ContentToDevice(
  783.     Environment* ev,
  784.     const FW_CRect& rectFrom,
  785.     FW_SPlatformRect& rectTo,
  786.     FW_CGraphicDevice* device,
  787.     ODTransform* transform) const
  788. {
  789.     CheckCache(ev, device, transform);
  790.  
  791.     rectTo = rectFrom.TransformCopy(ev, fContentToDeviceTransform);
  792. }
  793.  
  794. //----------------------------------------------------------------------------------------
  795. //    FW_CMapping::ContentToDevice
  796. //----------------------------------------------------------------------------------------
  797.  
  798. ODShape* FW_CMapping::ContentToDevice(
  799.     Environment* ev,
  800.     ODShape* shape,
  801.     FW_CGraphicDevice* device,
  802.     ODTransform* transform) const
  803. {
  804.     CheckCache(ev, device, transform);
  805.  
  806.     ODShape* newShape = shape->Copy(ev);
  807.     fContentToDeviceTransform->TransformShape(ev, newShape);
  808.     return newShape;
  809. }
  810.